<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>法援宝</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/mobiscroll_002.css" />
    <link rel="stylesheet" type="text/css" href="../css/baguetteBox.css" />

    <link rel="stylesheet" type="text/css" href="../css/lawyer_user.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/lawyer.js"></script>
    <script type="text/javascript" src="../script/baguetteBox.js"></script>
    <script type="text/javascript" src="../script/highlight.min.js"></script>

    <script src="../script/mobiscroll_002.js" type="text/javascript"></script>
    <script src="../script/mobiscroll_004.js" type="text/javascript"></script>
    <script src="../script/mobiscroll.js" type="text/javascript"></script>
    <script src="../script/mobiscroll_003.js" type="text/javascript"></script>
    <script src="../script/mobiscroll_005.js" type="text/javascript"></script>

    <style type="text/css">
        .gallery {
            display: flex;
            margin-top: 0.2rem;
        }

        .gallery a {
            width: 31%;
            margin-right: 3%;
        }

        .gallery a img {
            display: block;
            width: 2.22rem;
            height: 2.22rem;
        }

        .gallery a:last-child {
            margin-right: 0;
        }

        .full-image img {
            width: 100%!important;
        }
    </style>
</head>

<body>
    <div id="secHeader">
      <header class="header">
          <a href="javascript:void(0);" onclick="aaplay('lawyerquan')" class="back_btn"><img src="../image/head-fanhui.png" alt=""></a>
          <h2>动态详情</h2>
          <!--<a href="javascript:;" class="tel_btn">保存</a>-->
      </header>
    </div>
    <section class="lawyer_dynamic">
        <div class="lawyers_list">
            <ul>
                <li>
                    <div class="userInfo">
                        <img src="" id="lawyer_tx">
                        <div class="userName">
                            <h6><em id="lawyer_nickname"></em> <i>LV.6</i></h6>
                            <span id="lawyer_time"></span>
                        </div>
                    </div>
                    <div class="comment_info">
                        <p id="lawyer_info"></p>
                        <dl id="label">
                        </dl>
                    </div>
                </li>
            </ul>
        </div>
    </section>
    <section class="dynamic_info">
        <p class="dynamic_fabulous" id='dzname'>张岳伦律师、刘焕律师等125人觉得很赞</p>
        <p class="dynamic_forward" id='zfname'>189****8704等34人转发了动态</p>
    </section>
    <section class="comment_section">
        <div class="news_title">
            <h2>评论区(<em id="sum"></em>条)</h2>
        </div>
        <div class="comment_list">
            <ul id="plCon">
                <!--<li>
                <div class="userInfo">
                    <img src="../image/userimg1.jpg" alt="">
                    <div class="userName">
                        <h6>135****7574</h6>
                        <span>2018-11-11  14:45</span>
                    </div>
                </div>
                <div class="comment_info">
                    <p>担保人还从中作梗，以后要睁大眼睛选担保人了。</p>
                </div>
            </li>-->
            </ul>
        </div>
    </section>

    <section class="fixed_comment">
        <ul>
            <li><span class="collect_btn"></span></li>
            <li><input id="comment_info" type="text" placeholder="我来说两句"></li>
            <li><button class="comment_submit" type="button">发送</button></li>
        </ul>
    </section>

</body>
<script>
    var para = '';
    var page = 1;
    apiready = function() {
      $api.fixStatusBar( $api.dom('#secHeader') );
      api.setStatusBarStyle({
          style: 'light'
      });
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            
        });
        api.showProgress();

        //下拉刷新
        api.setRefreshHeaderInfo({
          visible: true,
          bgColor: 'rgba(255,255,255,255)',
          textColor: '#666',
          textDown: '下拉刷新',
          textUp: '释放刷新'
        }, function(ret, err) {
          toDoRefresh();
        });

        para = api.pageParam;

        var p = {
            model: 'dongtai',
            id: para.id
        };
        api.ajax({
            url: webSiteUrl + '/app/home/find',
            method: 'post',
            data: {
                values: p
            }
        }, function(ret, err) {


            api.hideProgress();
            console.log(JSON.stringify(ret))
            if (ret.code == 200) {
                //alert(JSON.stringify(ret.data));
                if (ck(ret.data.tx)) {
                    var u = ''
                } else {
                    var u = webSiteUrl
                }
                $('#lawyer_tx').attr('src', u + ret.data.tx);
                $('#lawyer_nickname').html(ret.data.name);
                $('#lawyer_time').html(ret.data.time);
                $('#lawyer_info').html(ret.data.content);
                //$('#dzname').html(ret.data.dzname+'等'+ret.data.dznum+'人觉得很赞');
                //$('#zfname').html(ret.data.zfname+'等'+ret.data.zfnum+'人转发了动态');
                $('#dzname').html(ret.data.dz + '人觉得很赞');
                $('#zfname').html(ret.data.zf + '人转发了动态');

                var str = '';
                if (ret.data.icon.length > 0) {
                    str += '<div class="baguetteBoxOne gallery">';
                    for (var i = 0; i < ret.data.icon.length; i++) {
                        str += '<dd><a href="' + webSiteUrl + ret.data.icon[i] + '" data-caption=""><img src=' + webSiteUrl + ret.data.icon[i] + ' alt=""></a></dd>'
                    }
                    str += '</div>';
                    $("#label").html(str)
                    baguetteBox.run('.baguetteBoxOne');
                }

                iscol();
            } else {
                alert(ret.msg)
            }
        });

    }

    function iscol() {
        var p = {
            token: token,
            id: para.id,
            type: 2
        };
        api.ajax({
            url: webSiteUrl + '/app/user/is_col',
            method: 'post',
            data: {
                values: p
            }
        }, function(ret, err) {
            if (ret.code == 200) {
                $('.collect_btn').addClass('active');
            } else {
                $('.collect_btn').removeClass('active');
            }
            toDoRequest()
        });
    }



    function toDoRequest() {

        var p = {
            id: para.id,
            type: 2
        };
        //alert(JSON.stringify(p))
        api.ajax({
            url: webSiteUrl + '/app/public/pl',
            method: 'post',
            data: {
                values: p
            }
        }, function(ret, err) {

            api.hideProgress();
            if (ret.code == 200) {

                var html = "";
                var pl = ret.data.com;
                if (pl != null) {
                    //alert(JSON.stringify(ret));
                    for (var j = 0; j < pl.length; j++) {
                        if (ck(pl[j].icon)) {
                            var u = ''
                        } else {
                            var u = webSiteUrl
                        }
                        html += '<li><div class="userInfo"><img src=' + u + pl[j].icon + ' alt=""><div class="userName"><h6>' + pl[j].phone + '</h6><span>' + pl[j].time + '</span></div></div><div class="comment_info"><p>' + pl[j].content +
                            '</p></div></li>'
                    }

                    $("#sum").html(pl.length);

                }

                $('#plCon').html(html);



            } else {
                if (page == 1) {
                    $('#plCon').html('<p style="text-align:center">暂无数据</p>');
                }

            }
        })


    }




    $('.collect_btn').click(function() {
        if(!loginCheck()){
          return false;
        }
        if ($(this).hasClass('active')) {
            var p = {
                token: token,
                id: para.id,
                type: 2
            }
            api.ajax({
                url: webSiteUrl + '/app/user/del_collection',
                method: 'post',
                data: {
                    values: p
                }
            }, function(ret, err) {
                if (ret.code == 200) {
                    $('.collect_btn').removeClass('active');
                    toDoRequest()
                }
            });

        } else {
            var p = {
                token: token,
                id: para.id,
                type: 2
            }
            api.ajax({
                url: webSiteUrl + '/app/user/add_collection',
                method: 'post',
                data: {
                    values: p
                }
            }, function(ret, err) {
                if (ret.code == 200) {
                    $('.collect_btn').addClass('active');
                    toDoRequest()
                }
            });

        }
    });
    //fa评论
    $('.comment_submit').click(function() {
        if(!loginCheck()){
          return false;
        }
        var val = $("#comment_info").val();
        if (val != '') {
            var p = {
                token: token,
                id: para.id,
                type: 2,
                content: val
            }
            api.ajax({
                url: webSiteUrl + '/app/user/addpl',
                method: 'post',
                data: {
                    values: p
                }
            }, function(ret, err) {
                api.hideProgress();

                if (ret.code == 200) {
                    //alert(JSON.stringify(ret))
                    var tj = ret.data
                    var html = '<li><div class="userInfo"><img src="' + webSiteUrl + tj.icon + '" alt=""><div class="userName"><h6>' + tj.phone + '</h6><span>' + tj.time + '</span></div></div><div class="comment_info"><p>' + tj.content +
                        '</p></div></li>';
                    if ($(".comment_list ul li").length > 0) {
                        $(".comment_list ul").prepend(html);
                    } else {
                        $(".comment_list ul").html(html);
                    }

                    $("#comment_info").val('')
                    toDoRequest()
                } else {
                    alert(ret.msg)
                }
            });



        } else {
            alert('请输入评论内容')
        }
    })
</script>

</html>
